home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 July
/
Macworld (1999-07).dmg
/
Shareware World
/
Info
/
For Developers
/
Mops 3.4.sea
/
Mops source
/
Toolbox classes
/
TEview
< prev
next >
Wrap
Text File
|
1996-11-05
|
4KB
|
218 lines
\ Aug 96 mrh Initial version
\ Sep 96 mrh added selectAll:, selectLine:
need window+
need TextEdit
\ TEView is a simple non-scrolling TextEdit view. It has some code
\ lifted from TEScroller, but is a lot simpler.
objptr $TMP class_is string+
:class TEView super{ view }
TextEdit theTE
byte mouse_was_here?
:m >font: ( font# -- ) >font: theTE ;m
:m >fontSize: ( n -- ) >fontSize: theTE ;m
:m >color: ( red green blue -- ) >color: theTE ;m
:m >style: ( n -- ) >style: theTE ;m
:m SIZE: \ ( -- n )
size: theTE ;m
:m ENABLE:
enable: super
activate: theTE ;m
:m DISABLE:
disable: super
deactivate: theTE ;m
:m MOVED: { \ x y dx dy adr -- }
getViewRect: self 2drop -> y -> x
moved: super
get: alive? 0EXIT
getViewRect: self setViewRect: theTE
getViewRect: self 2drop y - -> dy x - -> dx
\ now we must do some of the work in FixPanRect: of TEScroller. We
\ assume we're not wrapping.
handle: theTE @ -> adr
32766 getpoint: theTE -> y -> x
y adr 4+ w! \ Adjust bottom of dest rect and
800 adr 6 + w! \ right coordinate if not wrapping **** change as necessary
\ - 1600 for Mops, 500 for Scriptor. Make it an ivar soon!!
size: theTE
getpoint: theTE nip adr 4 + w! \ Adjust bottom of dest rect
dx dy or IF dx dy scroll: theTE THEN
^viewRect: self clear: class_as> rect
;m
:m (DRAW):
\ TE looks after clipping itself, so we don't need our default clipping.
\ It would cause problems anyway, since we use the grafport origin when
\ calling TE, while our default clipping uses view origin. So we
\ disable our own clipping.
false put: setClip?
noClip \ Experimentation shows this is definitely necessary!!
setTempRect: self
addr: tempRect call eraserect
addr: viewRect update: theTE
;m
:m DRAW: (draw): self ;m
:m SETSELECT: { strt end -- }
pushPort set: [ get: ^myWind ]
strt end select: theTE
\ update: [ get: ^myWind ]
popPort ;m
:m SELECTALL:
pushPort set: [ get: ^myWind ]
selectAll: theTE
popPort ;m
:m SELECTLINE:
getLine: theTE 2drop \ need sideffect of setting lineStart and lineEnd
lineStart lineEnd setSelect: self
;m
:m CARETLOC: \ ( -- x y )
selstart: theTE
getpoint: theTE ;m
:m CLICK:
click: super
click: theTE
;m
:m KEY: { char -- }
noClip \ it seems we can sometimes be clipped out
char key: theTE
;m
:m INSERT: \ ( addr len )
noClip \ it seems we can sometimes be clipped out
insert: theTE
;m
:m $INSERT: ( str -- ) { \ adr -- }
['] $tmp ! \ may be a subclass of string+
get: $tmp insert: self ;m
:m +: ( c -- )
pad c!
pad 1 insert: self ;m
:m NEW:
new: super
addr: viewRect dup new: theTE
;m
:m CUT: cut: theTE ;m
:m COPY: copy: theTE ;m
:m PASTE: paste: theTE ;m
:m CLEAR: clear: theTE ;m
:m CLEARALL: noclip selectAll: self clear: theTE ;m
:m TextHandle: textHandle: theTE ;m
:m GETSELECT: \ ( -- addr len ) \ return hilited selection
getselect: theTE ;m
\ getline: will return the entire line in which the cursor is currently in,
\ regardless of where in the line the cursor is located. No text need be
\ selected.
:m GETLINE: \ ( -- addr len )
getline: theTE ;m
:m RELEASE:
release: theTE ;m
:m HANDLE: \ ( -- TEhndl )
handle: theTE ;m
:m getText: \ ( -- addr len )
get: theTE ;m
:m SELEND: \ ( -- n )
selend: theTE ;m
:m SELSTART: \ ( -- n )
selstart: theTE ;m
:m LINEEND: \ ( -- n ) \ **
lineEnd: theTE ;m
private
:m check_mouse?: { \ mouseHere? -- mouseHere? changed? }
mouseHere?: self -> mouseHere?
mouseHere?
get: mouse_was_here? mouseHere? <>
mouseHere? put: mouse_was_here?
;m
public
:m IDLE:
idle: super
nil?: ^myWind ?EXIT
self
get: ^myWind get: ivar> ^view_in_focus in class_as> window
= 0EXIT \ do nothing else if we're not in focus
\ now we set the cursor if we have to - we only do this if the mouse
\ has just moved into or out of our area. Otherwise we do nothing.
\ This avoids pointer flickering problems.
check_mouse?: self
IF \ changed
( in our area? ) IF ibeamcurs ELSE arrowCurs THEN
ELSE drop
THEN
idle: theTE ;m
:m CLASSINIT:
classinit: super
set: canHaveFocus?
1 put: mouse_was_here? ;m
:m dump: dump: super dump: theTE ;m
;class